home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Database How-To / Visual Basic 4 Database - How-to (The Waite Group)(1995).iso / titles.cl_ / titles.cl
Text File  |  1995-07-05  |  1KB  |  52 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "clsTitles"
  6. Attribute VB_Creatable = True
  7. Attribute VB_Exposed = True
  8. Option Explicit
  9.  
  10. Private m_Coll As New Collection
  11. Private m_Database As String
  12.  
  13. Property Get Count() As Integer
  14.     Count = m_Coll.Count
  15. End Property
  16. Property Let DatabaseName(theDatabase As String)
  17.     m_Database = theDatabase
  18. End Property
  19. Property Get DatabaseName() As String
  20.     DatabaseName = m_Database
  21. End Property
  22. Public Sub Add(ti As clsTitle)
  23.     m_Coll.Add Item:=ti, KEY:=CStr(ti.ISBN)
  24. End Sub
  25. Public Sub Remove(theKey As Long)
  26.     m_Coll.Remove CStr(theKey)
  27. End Sub
  28. Public Function Item(theKey As Long) As clsAuthor
  29.     Set Item = m_Coll(CStr(theKey))
  30. End Function
  31. Public Sub Clear()
  32.     Dim i As Integer
  33.     For i = m_Coll.Count To 1 Step -1
  34.         m_Coll.Remove i
  35.     Next i
  36. End Sub
  37. Public Sub List(ctrl As Variant)
  38.     Dim i As Integer
  39.     If TypeOf ctrl Is ListBox Or TypeOf ctrl Is ComboBox Then
  40.         ctrl.Clear
  41.         For i = 1 To m_Coll.Count
  42.             If m_Coll(i).Title <> "" Then
  43.                 ctrl.AddItem m_Coll(i).Title
  44.             Else
  45.                 ctrl.AddItem "<no title>"
  46.             End If
  47.             ctrl.ItemData(ctrl.NewIndex) = i
  48.         Next i
  49.     End If
  50. End Sub
  51.  
  52.